package com.eeepay.eeepay_v2.util;

import java.util.Random;

/**
 * Created by zw on 2016/12/13 0013.
 */
public class ColorUitls {

    public static final String[] colors = {
            "#f47920", "#905a3d", "#faa755", "#ef5b9c", "#2b4490",
            "#d71345", "#7fb80e", "#181d4b", "#f26522", "#96582a",
            "#aa2116", "#c37e00", "#45224a", "#f15a22", "#122e29",
            "#402e4c", "#f47a55", "#ffd400", "#006c54", "#472d56",
            "#840228", "#2468a2", "#281f1d", "#b4532a", "#525f42",
            "#2f271d", "#c99979", "#5f5d46", "#1b315e", "#1d1626",};

    /**
     * add by zhuangzeqin 2017年8月29日14:11:02
     *
     * 生成随机颜色--tip 避免由于数组的长度变化；导致数组越界
     *
     * @return
     */
    public static final String getColorByRandom() {
        String r, g, b;
        Random random = new Random();
        r = Integer.toHexString(random.nextInt(256)).toUpperCase();
        g = Integer.toHexString(random.nextInt(256)).toUpperCase();
        b = Integer.toHexString(random.nextInt(256)).toUpperCase();

        r = r.length() == 1 ? "0" + r : r;
        g = g.length() == 1 ? "0" + g : g;
        b = b.length() == 1 ? "0" + b : b;
        //生成十六进制颜色值
        StringBuffer stringBuffer = new StringBuffer("#");
        stringBuffer.append(r).append(g).append(b);
        return stringBuffer.toString();
    }
}
